package resolvers

import (
	"happy-sudoku/graphql/graph"
	"happy-sudoku/internal/service"
)

// ResolverConfig is config for build resolvers
type ResolverConfig struct {
	PlayerSrv service.IPlayerService
	AuthSrv   service.IAuthService
	RoomSrv   service.IRoomService
	PuzzleSrv service.IPuzzleService
}

// RootResolver is the root of all resolvers
type RootResolver struct {
	playerSrv service.IPlayerService
	authSrv   service.IAuthService
	roomSrv   service.IRoomService
	puzzleSrv service.IPuzzleService
}

// NewRootResolver new root resolvers
func NewRootResolver(cfg ResolverConfig) *RootResolver {
	return &RootResolver{
		playerSrv: cfg.PlayerSrv,
		authSrv:   cfg.AuthSrv,
		roomSrv:   cfg.RoomSrv,
		puzzleSrv: cfg.PuzzleSrv,
	}
}

func (r *RootResolver) Mutation() graph.MutationResolver {
	return &mutationRootResolver{r}
}
func (r *RootResolver) Player() graph.PlayerResolver {
	return &playerRootResolver{r}
}
func (r *RootResolver) Query() graph.QueryResolver {
	return &queryRootResolver{r}
}
func (r *RootResolver) Room() graph.RoomResolver {
	return &roomRootResolver{r}
}
func (r *RootResolver) Subscription() graph.SubscriptionResolver {
	return &subscriptionRootResolver{r}
}
